{% extends 'base.html' %}

{% block js %}
<script>
    function click_zhan(){
        $.get('/post/zhan', {'post_id': '{{ post.id }}'}, function (data) {
            if(data.result == 'success'){

            }else{
                if(confirm('需要登录, 是否登录？')){
                    window.location.href = '/sign/in?next=' + window.location.href;
                }
            }
        })
    }
</script>
{% endblock %}

{% block content %}
<form method="post" action="/post/comment">
<input name="post_id" hidden value="{{ post.id }}">

<div class="center_div">
    <center>
        <div><h3>{{ post.title }}</h3></div>
{#        <div style="display:inline;"><img src="/{{ post.user.avatar_url }}" class="img-circle head_small"></div>#}
        <div style="display:inline;"><a href="/user/detail?user_id={{ post.user.id }}">{{ post.user.username }}</a>发表于&nbsp;{{ post.create_time|date:'Y-m-d H:i' }}</div>
        <br>
    </center>
    <br>
    {{ post.content }}
    <br><br><br>
    <div style="text-align: center;"><a style="color: #cc0000" onclick="click_zhan()">❤&nbsp;{{ post.zhan_count }}</a></div>
    <br>

    <textarea name="content" style="width: 100%;" placeholder="评论内容..."></textarea>
    <button type="submit">提交评论</button>
    <br><br>
    {% for c in comments %}
        #{{ forloop.counter }}&nbsp;&nbsp;<a style="font-size: smaller">{{ c.create_time|date:'Y-m-d H:i' }}</a><br>
            &nbsp;&nbsp;&nbsp;&nbsp;<a href="/user/detail?user_id={{ c.user.id }}">{{ c.user.username }}</a>:&nbsp;{{ c.content }}
        <br><br>
    {% endfor %}
</div>
</form>
{% endblock %}